﻿namespace Microsoft.Office.PowerPoint.STAMP.Controls
{
    /// <summary>
    /// Represents a font size.
    /// </summary>
    public class CaptionFontSize
    {
        private enum FontSizeType
        {
            Empty = 1,
            Auto = 2,
            Em = 3
        }

        private static readonly CaptionFontSize _empty = new CaptionFontSize(FontSizeType.Empty);
        private static readonly CaptionFontSize _auto = new CaptionFontSize(FontSizeType.Auto);
        
        private readonly float _pointSize;
        private readonly FontSizeType _fontSizeType;

        private CaptionFontSize(FontSizeType fontSizeType)
        {
            _fontSizeType = fontSizeType;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CaptionFontSize"/> class.
        /// </summary>
        /// <param name="pointSize">Size of the point.</param>
        public CaptionFontSize(float pointSize) : this(FontSizeType.Em)
        {
            _pointSize = pointSize;
        }

        /// <summary>
        /// Gets the size of the font in points.
        /// </summary>
        /// <value>
        /// The size of the point.
        /// </value>
        public float? PointSize
        {
            get { return _fontSizeType == FontSizeType.Em ? _pointSize : (float?) null; }
        }

        /// <summary>
        /// Gets the empty instance.
        /// </summary>
        public static CaptionFontSize Empty
        {
            get { return _empty; }
        }

        /// <summary>
        /// Gets a value indicating whether this is the empty instance
        /// </summary>
        public bool IsEmpty
        {
            get { return this == _empty; }
        }

        /// <summary>
        /// Gets the auto instance.
        /// </summary>
        public static CaptionFontSize Auto
        {
            get { return _auto; }
        }

        /// <summary>
        /// Gets a value indicating whether this is the auto instance
        /// </summary>
        public bool IsAuto
        {
            get { return this == _auto; }
        }

        /// <summary>
        /// Gets the text.
        /// </summary>
        public string Text
        {
            get
            {
                switch (_fontSizeType)
                {
                    case FontSizeType.Auto:
                        return "Auto";
                    case FontSizeType.Empty:
                        return "";
                    case FontSizeType.Em:
                        return PointSize.ToString();
                }
                return null;
            }
        }
    }
}